home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / mmdf / mmdf-IIb.43 / lib / addr / norm.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-02-01  |  2.0 KB  |  112 lines

  1. #include "util.h"
  2. #include "mmdf.h"
  3. #include "ap.h"
  4. #include "ch.h"
  5.  
  6. extern LLog *logptr;
  7.  
  8. extern int ap_outtype;
  9.  
  10. main (argc, argv)
  11. int argc;
  12. char *argv[];
  13. {
  14.     char adr [LINESIZE];
  15.     char *p;
  16.  
  17.     AP_ptr *ap;
  18.     AP_ptr *group;
  19.     AP_ptr *name;
  20.     AP_ptr *route;
  21.     AP_ptr *domain;
  22.     AP_ptr *local;
  23.     AP_ptr *norm;
  24.     int i;
  25.  
  26.     Chan *thechan;
  27.     char *dfldomain = (char *) 0;
  28.     char *dflhost = (char *) 0;
  29.  
  30.  
  31.     mmdf_init ("NORM");
  32.     logptr -> ll_level = LLOGFTR;
  33.     siginit ();
  34.  
  35.     if ((thechan = ch_nm2struct ("foo")) == (Chan *) NOTOK)
  36.     {
  37.     printf ("Chan foo not found\n");
  38.     thechan = (Chan *) 0;
  39.     }
  40.     else
  41.     {
  42.     printf ("channel '%s' used\n", thechan -> ch_show);
  43.     dfldomain = thechan -> ch_ldomain;
  44.     dflhost = thechan -> ch_lname;
  45.     }
  46.     fflush (stdout);
  47.  
  48.  
  49.     for (i=1; i < argc; i++)
  50.     {
  51.     printf ("received: '%s'\n", argv[i]);
  52.     fflush (stdout);
  53.  
  54.     ap = ap_s2tree (argv[i]);
  55.     if (ap == (AP_ptr) NOTOK)
  56.     {
  57.         printf ("Parse failed\n\n");
  58.         continue;
  59.     }
  60.     ap_outtype = AP_822;
  61.     ap_t2s (ap, &p);
  62.  
  63.     printf ("tree in full is: '%s'\n", p);
  64.     fflush (stdout);
  65.     free (p);
  66.  
  67.     norm = ap_normalize (dflhost, dfldomain, ap, thechan);
  68.     ap_t2s (norm, &p);
  69.     printf ("normalised tree (822, little) is: '%s' \n", p);
  70.     fflush (stdout);
  71.     free (p);
  72.  
  73.     ap_t2parts (ap, &group, &name, &local, &domain, &route);
  74.     p = ap_p2s ((AP_ptr) 0, (AP_ptr) 0, local, domain, route);
  75.     printf ("real  bits: '%s'\n", p);
  76.     fflush (stdout);
  77.     free (p);
  78.  
  79.     ap_outtype = AP_733;
  80.     ap_t2s (norm, &p);
  81.     printf ("normalised tree (jnt, little) is: '%s' \n", p);
  82.     fflush (stdout);
  83.     free (p);
  84.     ap_outtype = (AP_822  | AP_BIG);
  85.     ap_t2s (norm, &p);
  86.     printf ("normalised tree (822, big) is: '%s' \n", p);
  87.     free (p);
  88.     fflush (stdout);
  89.     if (thechan == NULL)
  90.         continue;
  91.     ap_outtype = thechan -> ch_apout;
  92.     ap_t2s (norm, &p);
  93.     printf ("normalised tree (from channel type) is: '%s' \n", p);
  94.     free (p);
  95.  
  96.     printf ("\n\n");
  97.     fflush (stdout);
  98.  
  99.     }
  100. }
  101.  
  102. err_abrt (code, fmt, b, c, d)
  103. char code,
  104.     *fmt, *b, *c, *d;
  105. {
  106. printf ("norm aborting (%s)\n", rp_valstr (code));
  107. printf (fmt, b, c, d);
  108. fflush (stdout);
  109. exit (0);
  110. }
  111.  
  112.